// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


/**
 * @fileoverview Unit tests for bite.layer.ConsoleBehavior.
 *
 * @author jasonstredwick@google.com (Jason Stredwick)
 */


goog.require('bite.layer.ConsoleBehavior');
goog.require('goog.testing.PropertyReplacer');


var stubs_ = new goog.testing.PropertyReplacer();


function setUp() {
}


function tearDown() {
  stubs_.reset();
}


/**
 * @extends {bite.layer.ConsoleBehavior}
 * @constructor
 */
var Derived = function() {
  goog.base(this);

  this.element = {'style': {}};

  var property = bite.layer.ConsoleBehavior.Property_.VISIBILITY;
  this.element['style'][bite.layer.ConsoleBehavior.Property_.VISIBILITY] =
      bite.layer.ConsoleBehavior.State_.VISIBILITY_ON;

  this.setBehavior(this.element);
};
goog.inherits(Derived, bite.layer.ConsoleBehavior);


/*
 * This test simply validates the creation process of the Derived class and
 * its data.
 */
function testDerivedCreation() {
  var obj = new Derived();

  assertNotNull('New object is null.', obj);
  assertNotNull('New object element is null.', obj.element);
  assertNotNull('New object control element is null.',
                obj.consoleBehaviorTarget_);

  assertEquals(obj.element, obj.consoleBehaviorTarget_);
  assertTrue('style' in obj.element);
  assertEquals(bite.layer.ConsoleBehavior.State_.VISIBILITY_ON,
      obj.element['style'][bite.layer.ConsoleBehavior.Property_.VISIBILITY]);
}


function testDisable() {
  var obj = new Derived();

  assertFalse(obj.isDisabled());
  obj.disable();
  assertTrue(obj.isDisabled());
  obj.enable();
  assertFalse(obj.isDisabled());
}


function testVisibility() {
  var obj = new Derived();

  assertTrue(obj.isVisible());
  obj.hide();
  assertFalse(obj.isVisible());
  obj.show();
  assertTrue(obj.isVisible());
}

